package com.qf.test;

import com.qf.service.UserService;
import com.qf.service.impl.UserServiceImpl;
import org.junit.Test;

import java.lang.reflect.Proxy;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/9/28 20:31
 */

public class Demo2 {
    @Test
    public void jdkDynamicProxyTest(){
        //创建被代理对象
        UserService userService = new UserServiceImpl();

        //创建代理对象
        UserService userServiceProxy = (UserService) Proxy.newProxyInstance(userService.getClass().getClassLoader(),userService.getClass().getInterfaces(),new JDKDynamicProxy(userService));

        //执行
        userService.save();

    }
}
